import React from 'react'
import PureRenderMixin from 'react-addons-pure-render-mixin';
import { getInfoData } from '../../../fetch/detail/detai';

import DetailInfo from '../../../components/DetailInfo/index.jsx'

class Info extends React.Component {
    constructor(props, context) {
        super(props, context);
         this.state = {
            info: false
        }
        this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
    }
    render() {
        return (
            <div>
            	{
            		this.state.info ? 
            		<DetailInfo
            			{...{
            				Infodata:this.state.info
            			}}

            		/> :<div>占时未找到该商户的数据</div>
            	}
            </div>
        )
    }
    //获取数据]
    componentDidMount() {
    	var id = this.props.id;
    	//请求商户数据参数为ID(返回Promise对象)
    	var result = getInfoData(id);
    	//console.log(result)
    	result.then(res => {
    		return res.json()
    	}).then(json => {
    		//console.log(json)
    		this.setState({
    			info:json 
    		});
    	})
    }
}

// 使用 require.ensure 异步加载，还不支持 ES6 的 export 
// export default 
module.exports = Info